<!DOCTYPE HTML>
<html lang="zh-cn" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=11; IE=10; IE=9; IE=8; IE=7; IE=EDGE" />
        <title>用法 | Domplate 文档</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.0.1">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
        <link rel="stylesheet" href="../gitbook/prettify/prettify.css" />
        
    
    
    <link rel="next" href="../features/index.html" />
    
    
    <link rel="prev" href="../index.html" />
    

        
    </head>
    <body>
        
        
    <link rel="stylesheet" href="../gitbook/style.css">
    
    

        
    <div class="book" data-level="1" data-basepath=".." data-revision="Tue May 19 2015 01:42:16 GMT+0800 (CST)">
    

<div class="book-summary">
    <div class="book-search">
        <input type="text" placeholder="输入并搜索" class="form-control" />
    </div>
    <ul class="summary">
        
        
        
        

        

        
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../index.html">
                        <i class="fa fa-check"></i>
                        
                        介绍
                    </a>
                
            
            
        </li>
    
        <li class="chapter active" data-level="1" data-path="usage/index.html">
            
                
                    <a href="../usage/index.html">
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        用法
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="2" data-path="features/index.html">
            
                
                    <a href="../features/index.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        特性
                    </a>
                
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="features/expression.html">
            
                
                    <a href="../features/expression.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        表达式
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="features/init.html">
            
                
                    <a href="../features/init.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        数据初始化属性
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="features/flow.html">
            
                
                    <a href="../features/flow.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        流程控制属性
                    </a>
                
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.3.1" data-path="features/show.html">
            
                
                    <a href="../features/show.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.1.</b>
                        
                        show
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="2.3.2" data-path="features/repeat.html">
            
                
                    <a href="../features/repeat.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.2.</b>
                        
                        repeat
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="2.3.3" data-path="features/switch.html">
            
                
                    <a href="../features/switch.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.3.</b>
                        
                        switch
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="features/event.html">
            
                
                    <a href="../features/event.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        事件属性
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="jsapi/index.html">
            
                
                    <a href="../jsapi/index.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        JS 接口
                    </a>
                
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="jsapi/domplate.html">
            
                
                    <a href="../jsapi/domplate.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        domplate() 函数
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="jsapi/ctrl.html">
            
                
                    <a href="../jsapi/ctrl.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        ctrl 对象
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="jsapi/data.html">
            
                
                    <a href="../jsapi/data.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        ctrl.data 属性
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="jsapi/load.html">
            
                
                    <a href="../jsapi/load.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.</b>
                        
                        ctrl.load() 方法
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="jsapi/methods.html">
            
                
                    <a href="../jsapi/methods.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.5.</b>
                        
                        ctrl.methods() 方法
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="jsapi/update.html">
            
                
                    <a href="../jsapi/update.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.6.</b>
                        
                        ctrl.update() 方法
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" data-path="about/me.html">
            
                
                    <a href="../about/me.html">
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        其它
                    </a>
                
            
            
        </li>
    


        
        <li class="divider"></li>
        <li>
            <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                本书使用 GitBook 发布
            </a>
        </li>
        
    </ul>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header">
    <!-- Actions Left -->
    <a href="#" class="btn pull-left toggle-summary" aria-label="目录"><i class="fa fa-align-justify"></i></a>
    <a href="#" class="btn pull-left toggle-search" aria-label="搜索"><i class="fa fa-search"></i></a>
    
    <div id="font-settings-wrapper" class="dropdown pull-left">
        <a href="#" class="btn toggle-dropdown" aria-label="字体设置"><i class="fa fa-font"></i>
        </a>
        <div class="dropdown-menu font-settings">
    <div class="dropdown-caret">
        <span class="caret-outer"></span>
        <span class="caret-inner"></span>
    </div>

    <div class="buttons">
        <button type="button" id="reduce-font-size" class="button size-2">A</button>
        <button type="button" id="enlarge-font-size" class="button size-2">A</button>
    </div>

    <div class="buttons font-family-list">
        <button type="button" data-font="0" class="button">衬线体</button>
        <button type="button" data-font="1" class="button">无衬线体</button>
    </div>

    <div class="buttons color-theme-list">
        <button type="button" id="color-theme-preview-0" class="button size-3" data-theme="0">白色</button>
        <button type="button" id="color-theme-preview-1" class="button size-3" data-theme="1">棕褐色</button>
        <button type="button" id="color-theme-preview-2" class="button size-3" data-theme="2">夜间</button>
    </div>
</div>

    </div>

    <!-- Actions Right -->
    
    <div class="dropdown pull-right">
        <a href="#" class="btn toggle-dropdown" aria-label="分享"><i class="fa fa-share-alt"></i>
        </a>
        <div class="dropdown-menu font-settings dropdown-left">
            <div class="dropdown-caret">
                <span class="caret-outer"></span>
                <span class="caret-inner"></span>
            </div>
            <div class="buttons">
                <button type="button" data-sharing="twitter" class="button">
                    分享到 Twitter
                </button>
                <button type="button" data-sharing="google-plus" class="button">
                    分享到 Google
                </button>
                <button type="button" data-sharing="facebook" class="button">
                    分享到 Facebook
                </button>
                <button type="button" data-sharing="weibo" class="button">
                    分享到 Weibo
                </button>
                <button type="button" data-sharing="instapaper" class="button">
                    分享到 Instapaper
                </button>
            </div>
        </div>
    </div>
    

    
    <a href="#" target="_blank" class="btn pull-right google-plus-sharing-link sharing-link" data-sharing="google-plus" aria-label="Google"><i class="fa fa-google-plus"></i></a>
    
    
    <a href="#" target="_blank" class="btn pull-right facebook-sharing-link sharing-link" data-sharing="facebook" aria-label="Facebook"><i class="fa fa-facebook"></i></a>
    
    
    <a href="#" target="_blank" class="btn pull-right twitter-sharing-link sharing-link" data-sharing="twitter" aria-label="Twitter"><i class="fa fa-twitter"></i></a>
    
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../" >Domplate 文档</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="%E7%94%A8%E6%B3%95">&#x7528;&#x6CD5;</h1>
<h2 id="%E5%9F%BA%E6%9C%AC%E7%94%A8%E6%B3%95">&#x57FA;&#x672C;&#x7528;&#x6CD5;</h2>
<p>&#x8981;&#x5728;&#x9875;&#x9762;&#x4E0A;&#x5E94;&#x7528; domplate&#xFF0C;&#x9700;&#x8981;&#x5728; <code>&lt;head&gt;</code> &#x6807;&#x7B7E;&#x5185;&#x5F15;&#x7528; domplate.js&#xFF0C;&#x5E76;&#x4F7F;&#x7528; domplate &#x63D0;&#x4F9B;&#x7684; api &#x5BF9;&#x6307;&#x5B9A;&#x7684; element &#x5143;&#x7D20;&#x8FDB;&#x884C;&#x521D;&#x59CB;&#x5316;&#xFF1A;</p>
<pre><code class="prettyprint lang-html">&lt;html&gt;
&lt;head&gt;
  &lt;script src=&quot;&#x200C;path/to/domplate.js&#x200D;&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;div id=&quot;container&quot;&gt;
    &lt;p&gt;Hello, {{ name }}!&lt;/p&gt;
  &lt;/div&gt;
  &lt;script&gt;
    &#x200C;domplate( &quot;#container&quot; )&#x200D;.load( { name: &quot;domplate&quot; } );
  &lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<div class="display-demo-link" data-name="basic"></div>

<p>domplate &#x5C06;&#x4EE5;&#x7279;&#x5B9A;&#x7684;&#x6A21;&#x677F;&#x8BED;&#x6CD5;&#x89E3;&#x6790; #container &#x5143;&#x7D20;&#xFF0C;&#x5E76;&#x6839;&#x636E;&#x6570;&#x636E;&#x8FDB;&#x884C;&#x9996;&#x6B21;&#x6E32;&#x67D3;&#x3002;</p>
<h4 id="%E8%84%9A%E6%9C%AC%E6%96%87%E4%BB%B6%E4%B8%8B%E8%BD%BD%E5%9C%B0%E5%9D%80">&#x811A;&#x672C;&#x6587;&#x4EF6;&#x4E0B;&#x8F7D;&#x5730;&#x5740;</h4>
<div class="display-domplate-js-link"></div>

<p>&#x4E5F;&#x6B22;&#x8FCE; fork domplate &#x7684;&#x4ED3;&#x5E93;&#xFF1A;<a href="https://github.com/ChineseDron/domplate" target="_blank">https://github.com/ChineseDron/domplate</a></p>
<h2 id="%E4%BD%BF%E7%94%A8%E6%A8%A1%E5%9D%97%E5%8A%A0%E8%BD%BD%E5%99%A8">&#x4F7F;&#x7528;&#x6A21;&#x5757;&#x52A0;&#x8F7D;&#x5668;</h2>
<p>&#x5982;&#x679C;&#x9875;&#x9762;&#x4E0A;&#x6709; commonjs &#x6A21;&#x5757;&#x52A0;&#x8F7D;&#x5668;&#xFF08;&#x5982; require.js&#xFF09;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x6A21;&#x5757;&#x52A0;&#x8F7D;&#x5668;&#x7684; use &#x65B9;&#x6CD5;&#x8F7D;&#x5165; <code>domplate.js</code>&#xFF0C;&#x6216;&#x8005;&#x7528; require &#x51FD;&#x6570;&#x6216;&#x5B83;&#x6253;&#x5305;&#x5728;&#x4E00;&#x8D77;&#x3002;</p>
<h2 id="%E5%85%B6%E5%AE%83%E8%AF%B4%E6%98%8E">&#x5176;&#x5B83;&#x8BF4;&#x660E;</h2>
<p>&#x4E00;&#x4E2A; <code>domplate(...)</code> &#x8C03;&#x7528;&#xFF0C;&#x79F0;&#x4E3A;&#x4E00;&#x4E2A; domplate &#x5E94;&#x7528;&#x3002;</p>
<p>&#x540C;&#x4E00;&#x4E2A;&#x9875;&#x9762;&#x4E0A;&#x5141;&#x8BB8;&#x591A;&#x4E2A; domplate &#x5E94;&#x7528;&#xFF0C;&#x4F46;&#x539F;&#x5219;&#x4E0A;&#x5E94;&#x7528;&#x4E4B;&#x95F4;&#x7684;&#x5BB9;&#x5668;&#x5143;&#x7D20;&#x4E0D;&#x53EF;&#x4EE5;&#x5D4C;&#x5957;&#xFF0C;&#x5982;&#x679C;&#x5B58;&#x5728;&#x5D4C;&#x5957;&#x60C5;&#x51B5;&#xFF0C;&#x5219;&#x6709;&#x4EE5;&#x4E0B;&#x4E24;&#x79CD;&#x53EF;&#x80FD;&#xFF1A;</p>
<blockquote>
<ol>
<li>&#x5148;&#x521D;&#x59CB;&#x5316;&#x7236;&#x5BB9;&#x5668;&#x5E94;&#x7528;&#xFF0C;&#x540E;&#x521D;&#x59CB;&#x5316;&#x5B50;&#x5B59;&#x5BB9;&#x5668;&#x5E94;&#x7528;&#xFF0C;&#x5219;&#x5B50;&#x5B59;&#x5BB9;&#x5668;&#x5E94;&#x7528;&#x65E0;&#x6548;&#xFF1B;   </li>
<li>&#x5148;&#x521D;&#x59CB;&#x5316;&#x5B50;&#x5BB9;&#x5668;&#x5E94;&#x7528;&#xFF0C;&#x540E;&#x521D;&#x59CB;&#x5316;&#x7956;&#x7236;&#x5BB9;&#x5668;&#x5E94;&#x7528;&#xFF0C;&#x5219;&#x4E24;&#x4E2A;&#x5E94;&#x7528;&#x5747;&#x53EF;&#x72EC;&#x7ACB;&#x8FD0;&#x4F5C;&#xFF0C;&#x4F46;&#x662F;&#x7236;&#x5E94;&#x7528;&#x5728;&#x9047;&#x5230;&#x5B50;&#x5BB9;&#x5668;&#x5E94;&#x7528;&#x6240;&#x5904;&#x7684; dom &#x5143;&#x7D20;&#x5728;&#x5904;&#x7406;&#x65F6;&#x4F1A;&#x88AB;&#x5FFD;&#x7565;&#xFF1B;</li>
</ol>
</blockquote>
<p>&#x9605;&#x8BFB;&#x4EE5;&#x4E0B;&#x5B50;&#x7AE0;&#x8282;&#x4EE5;&#x7EE7;&#x7EED;&#x4E86;&#x89E3;&#xFF1A;</p>
<div class="display-sub-chapter" data-root="" data-except="&#x4ECB;&#x7ECD;,&#x7528;&#x6CD5;"></div>


                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../index.html" class="navigation navigation-prev " aria-label="Previous page: 介绍"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../features/index.html" class="navigation navigation-next " aria-label="Next page: 特性"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../gitbook/app-min.js"></script>
<script src="../gitbook/prettify/prettify.js"></script>
<script src="../common/inject-min.js"></script>

<script>
require(["gitbook"], function(gitbook) {
    var config = {"fontSettings":{"theme":null,"family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
